package com.jdk.learn;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import java.net.URI;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Pattern;

/**
 * Created by baiguantao on 2017/4/25.
 */
public class TemTest {
    static final  int b=10;
    public static void main(String[] args) {
        Map<String,Object> map=new LinkedHashMap<String,Object>();
        map.put("first","回款通知");
        Map<String,Object> data=new LinkedHashMap<String,Object>();
        data.put("keyword1","100元");
        data.put("keyword2","1000元");
        data.put("keyword3","11.22元");
        map.put("data",JSONArray.toJSONString(data));
        System.out.println(JSONArray.toJSONString(map));
        JSONObject newjsonobj=new JSONObject();
        newjsonobj.put("tt","ttval");
        newjsonobj.put("tt2","tt2val");
        newjsonobj.put("tt3","tt3val");
        Set<Map.Entry<String,Object>> sets=newjsonobj.entrySet();
        Pattern p=Pattern.compile("[a-z]");
        String s="<html><head><title>我是标题</title></head></html>";
        System.out.println(s);

    }

    private void test(){
        int a=1;
        final int b=2;
        switch (a) {
            case 1:
            case b:
                break;
            default:{

            }
        }
        JSONObject jsonRet=new JSONObject();
        jsonRet.put("tt","ttval");
        jsonRet.put("tt2","tt2val");
        jsonRet.put("tt3","tt3val");
        Set<Map.Entry<String,Object>> sets=jsonRet.entrySet();
        ExecutorService executorService=Executors.newWorkStealingPool();
        ArrayList<Map<String,String>> arrayList=new ArrayList<Map<String,String>>();
        Map<String,String> tem=new HashMap<String, String>();
            tem.put("amount",String.valueOf(10));
            tem.put("bizType","8001");
            tem.put("ftype","01"); //遍历的时候存入子表中
            tem.put("payUserId","rickyuserid5");
            tem.put("receiveUserId","111");
            tem.put("subOrderId",String.valueOf("22"));
            arrayList.add(tem);
        String url="http://gt.tunnel.qydev.com/trade/batchTransfer?subOrderList="+ URLEncoder.encode(JSONArray.toJSONString(arrayList))+"&currency=CNY&callbackUrl=http://gt.tunnel.qydev.com/trade/batchTransferNotify";
        HttpClient httpClient=new DefaultHttpClient();
        HttpGet httpGet=new HttpGet();
        HttpResponse response = null;
        try {
            httpGet.setURI(new URI(url));
            response=httpClient.execute(httpGet);

        }  catch (Exception e) {
            e.printStackTrace();
        }finally {
            httpGet.releaseConnection();
        }

        ArrayList<Map<String,String>> arrayList2=new ArrayList<Map<String,String>>();
        Map<String,String> tem2=new HashMap<String, String>();
        tem2.put("remark","服务费");
        tem2.put("subOrderId",  (UUID.randomUUID().toString().replace("-","")));
        tem2.put("receiveUserId","111");
        tem2.put("amount",String.valueOf(1));
        arrayList2.add(tem2);
        System.out.println(JSONArray.toJSONString(arrayList2));
/*
        final  int a=10;
        switch (a){
            case b:
                System.out.println(1);
            case 2:
                System.out.println("2");
            default:
                System.out.println("default");
        }*/


    }
    public void testCGFK(){
        // 包装业务请求参数开始
        Map<String, String> params = new HashMap<String, String>();

        params.put("orderId", "11111");
        params.put("bidId", "7cf13fc55fa54f90a578aac38848be6c"); // 标的Id
        params.put("userId", "90bb406d31df11e6996cd89d672a6a84"); // 借款人
        params.put("currency", "01"); // 币种
        params.put("totalNum", "1"); // 放款总笔数=投资总数
        params.put("totalAmount", "20000"); // 放款总金额,单位（分）
        params.put("grantAmount", "15000"); // 借款人实际收款金额，单位（分）

        Map<String,Object> shareProfitOrderList=new LinkedHashMap<String,Object>();
        shareProfitOrderList.put("keyword1","100元");
        shareProfitOrderList.put("keyword2","1000元");
        shareProfitOrderList.put("keyword3","11.22元");

        params.put("shareProfitOrderList", JSONArray.toJSONString(shareProfitOrderList)); // <子单集合>

        params.put("callbackUrl", "http://zhiyong.tunnel.2bdata.com/payment/trade/tradebidgrantNotify"); // 放款回掉地址

    }
}
